<template>
	<view>
		<zy-title></zy-title>
		
		<view class="zy-page-padding">
			<view class="zy-title-bar-title zy-mt-lg"> 实名认证 </view>
			<view class="zy-text-whitegrey zy-mt-50">根据相关规定要求，用户需完成实名认证并审核通过后才能进行充值、消费及收益等行为，实名认证不涉及金钱账号，且平台对认证信息严格保密</view>
			<view class="zy-row zy-mt-100 zy-pv-lg">
				<view class="zy-text-whitegrey-lg-bold"> 真实姓名 </view>
				<input class="zy-flex zy-text-white-lg" style="text-align: right;" placeholder="请输入正确的姓名" v-model="name"/>
			</view>
			<zy-line></zy-line>
			<view class="zy-row  zy-pv-lg">
				<view class="zy-text-whitegrey-lg-bold"> 身份证号 </view>
				<input class="zy-flex zy-text-white-lg" style="text-align: right;" placeholder="请输入正确的身份证号" v-model="id"/>
			</view>
			<zy-line></zy-line>
			
			<zy-button content="确认" @click="onSubmit" style="margin: 100rpx 30rpx;"></zy-button>
		</view>
	</view>
</template>

<script>
	import CacheUtil from '@/main/common/CacheUtil';
	import RouteUtil from '@/main/common/RouteUtil';

	export default {
		data() {
			return {
				name: '',
				id: '',
				nameHint: '请输入姓名',
				idHint: '请输入身份证号',
			}
		},
		methods: {
			choosePhoto(type) {
				const carmeraAvatar = CacheUtil.getCarmeraReal();
				if (carmeraAvatar) {
					this.uploadOOS(type)
					return
				}
				uni.showModal({
					content: '拍照功能用于实名认证',
					success: res => {
						if (res.confirm) {
							CacheUtil.setCarmeraReal();
							this.uploadOOS(type)
						}
					}
				})
			},
			onSubmit() {
				if ('' == this.name) {
					uni.$toast.showToast(this.nameHint)
					return
				}
				if ('' == this.id) {
					uni.$toast.showToast(this.idHint)
					return
				}
				this.requestSave();
			},

			async requestSave() {
				let params = {
					name: this.name,
					idCardNum: this.id,
					type: "1",
				};
				uni.$http.post("/api/authUser/Auth", params).then(res=>{
					uni.$toast.showToast('提交成功')
					RouteUtil.back()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>